//这个例子说明proxy操作的是目标函数
var target={};
var handler={};
var proxy=new Proxy(target,handler);
proxy.a='test';
console.log(target.a);
//这个例子测试对象方法的写法模式
var proxy=new Proxy({},{
	get:function(target,handler){
		return 35;
	}
});
console.log(proxy.mmp);
//具体proxy的实现
var handler={
	get:function(target,name){
		if(name=='prototype'){
			return Object.prototype;
		}
		return 'Hello,'+name;
	},
	apply:function(target,thisBinding,args){
		return args[0];
	},
	construct:function(target,args){
		return {value:args[1]};
	}
};
var fproxy=new Proxy(function(x,y){
	return x+y;
},handler);
var total=fproxy(1,2);
console.log(total);
console.log(new fproxy(1,2));
console.log(fproxy.foo);
//get属性的具体使用
var person={
	'name':'zjh',
	'age':18
}
var proxy=new Proxy(person,{
	get:function(target,proper){
		if(proper in target){
			return target[proper];
		}else{
			return 'the proper is not exist';
		}
	}
});
console.log(proxy.name);
console.log(proxy.age2);
//对象继承对象？
var obj=Object.create(proxy);
console.log(obj.age);
console.log(obj.age2);
//Reflect的高级使用
var myObject={
	foo:1,
	bar:2,
	get bzr(){
		return this.foo+this.bar;
	}
}
console.log(Reflect.get(myObject,'foo'));
console.log(Reflect.get(myObject,'bar'));
console.log(Reflect.get(myObject,'bzr'));
//Reflect和proxy的结合使用
let p={
	a:'a'
};
var handler={
	set(target,key,value,reciver){
		console.log('set');
		if(key=='a'){
			value=3;
		}
		Reflect.set(target,key,value,reciver);
	},
	defineProperty(target,key,attribute){
		console.log('defineProperty');
		Reflect.defineProperty(target,key,attribute);
	}
};
var proxy=new Proxy(p,handler);
proxy.a='A';
console.log(proxy.a);
//js旧类的使用
function Greeting(name){
	this.name=name;
	this.getSub=function(x,y){
		return x+y;
	};
}
var greet=new Greeting('me');
console.log(greet.name);
console.log(greet.getSub(4,117));
//用Reflect的新写法
const instance = Reflect.construct(Greeting, ['张三']);
console.log(instance.name);
console.log(instance.getSub(4,117));
//对js的prototype进行测试并进行总结和归纳
function Dog(){
	
}
Dog.prototype.name='二哈';
var dog=new Dog();
console.log(dog.name);





